home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW etc / MPW-PR / Interfaces&Libraries / Multiprocessing StdCLib / CIncludes / time.h < prev   
Encoding:
C/C++ Source or Header  |  1997-03-06  |  3.4 KB  |  155 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        time.h
  3.  
  4.      Contains:    Date and time
  5.  
  6.      Version:    Technology:    StdCLib 3.4
  7.                  Release:    3.6d2
  8.  
  9.      Copyright:    © 1987-1996 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18.  
  19. #ifndef __TIME_H__
  20. #define __TIME_H__
  21.  
  22. #ifndef __CONDITIONALMACROS__
  23. #include <ConditionalMacros.h>
  24. #endif
  25.  
  26.  
  27. /*
  28.  * Get common declarations 
  29.  */
  30.  
  31. #ifndef __NULLDEF__
  32. #include <NullDef.h>
  33. #endif
  34. #ifndef __SIZETDEF__
  35. #include <SizeTDef.h>
  36. #endif
  37.  
  38.  
  39. #if PRAGMA_ONCE_SUPPORTED
  40. #pragma once
  41. #endif  /* PRAGMA_ONCE_SUPPORTED */
  42.  
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46.  
  47. #if PRAGMA_IMPORT_SUPPORTED
  48. #pragma import on
  49. #endif
  50.  
  51. #if PRAGMA_ALIGN_SUPPORTED
  52. #pragma options align=mac68k
  53. #elif PRAGMA_PACK_SUPPORTED
  54. #pragma pack(push, 2)
  55. #endif
  56.  
  57.  
  58.  
  59.  
  60. /*
  61.  *    Declarations
  62.  */
  63.  
  64. #define CLOCKS_PER_SEC 60
  65. typedef unsigned long                     clock_t;
  66. typedef unsigned long                     time_t;
  67.  
  68. struct tm {
  69.     int                             tm_sec;                        /* Seconds after the minute -- [0, 61] */
  70.     int                             tm_min;                        /* Minutes after the hour -- [0, 59] */
  71.     int                             tm_hour;                    /* Hours after midnight -- [0, 23] */
  72.     int                             tm_mday;                    /* Day of the month -- [1, 31] */
  73.     int                             tm_mon;                        /* Months since January -- [0, 11] */
  74.     int                             tm_year;                    /* Years since 1900 */
  75.     int                             tm_wday;                    /* Days since Sunday -- [0, 6] */
  76.     int                             tm_yday;                    /* Days since January 1 -- [0, 365] */
  77.     int                             tm_isdst;                    /* Daylight Savings Time flag */
  78. };
  79. typedef struct tm tm;
  80.  
  81.  
  82. /*
  83.  *    Time manipulation functions
  84.  */
  85.  
  86. extern clock_t clock(void );
  87. /* function */
  88. #ifndef GENERATINGPOWERPC
  89. #ifndef __CFM68K__
  90.     #define clock() __tickcount()            /* macro - use TickCount() */
  91. extern pascal unsigned long __tickcount(void )
  92.  ONEWORDINLINE(0xA975);
  93.  
  94. #endif  /*  ! defined(__CFM68K__)  */
  95.  
  96. #endif  /*  ! defined(GENERATINGPOWERPC)  */
  97.  
  98.  
  99. extern double difftime(time_t time1, time_t time0);
  100. /* function */
  101. #define difftime(time1,time0) ((long double)time1 - time0)    /* macro */
  102.  
  103. extern time_t mktime(tm *timeptr);
  104. extern time_t time(time_t *timer);
  105.  
  106. /*
  107.  *    Time conversion functions
  108.  */
  109.  
  110. extern char *asctime(const tm *timeptr);
  111. extern char *ctime(const time_t *timer);
  112. extern tm *gmtime(const time_t *timer);
  113. extern tm *localtime(const time_t *timer);
  114. extern size_t strftime(char *s, size_t maxsize, const char *format, const tm *timerptr);
  115.  
  116. /*
  117.     Re-entrant-safe functions. The functions, "asctime_r",
  118.     "ctime_r", "gmtime_r", and "localtime_r" are safe to 
  119.     use in re-entrant situations including preemptive
  120.     68k threads or preemptive tasks provided by the
  121.     Multiprocessing Library for PowerPC/System 7.
  122.  
  123.     To make the prototypes for these functions visible, 
  124.     you must #define _POSIX_THREAD_SAFE_FUNCTIONS 1
  125.     via command-line compiler-directive or equivalent
  126.     option.  These functions are not available in versions
  127.     of StdCLib prior to 3.5a1.
  128. */
  129.  
  130. #if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
  131. extern char *asctime_r(const tm *timeptr, char *buf);
  132. extern char *ctime_r(const time_t *timer, char *buf);
  133. extern tm *gmtime_r(const time_t *timer, tm *result);
  134. extern tm *localtime_r(const time_t *timer, tm *result);
  135. #endif  /*  defined(_POSIX_THREAD_SAFE_FUNCTIONS)  */
  136.  
  137.  
  138.  
  139. #if PRAGMA_ALIGN_SUPPORTED
  140. #pragma options align=reset
  141. #elif PRAGMA_PACK_SUPPORTED
  142. #pragma pack(pop)
  143. #endif
  144.  
  145. #if PRAGMA_IMPORT_SUPPORTED
  146. #pragma import off
  147. #endif
  148.  
  149. #ifdef __cplusplus
  150. }
  151. #endif
  152.  
  153. #endif /* __TIME_H__ */
  154.  
  155.